package edu.towson.cosc603.coffeemaker;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

/**
 * Test case for the Recipe class.
 * 
 * @author Odessa
 */
public class RecipeTest extends TestCase
{

	/** The r1. */
	Recipe r1;



	/**
	 * Sets up the fixture for the test.
	 * 
	 * @throws Exception the exception
	 */
	@Before
	public void setUp() throws Exception
	{
		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(1);
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#getAmtChocolate()}.
	 */
	@Test
	public void testGetAmtChocolate()
	{
		assertEquals(1, r1.getAmtChocolate());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setAmtChocolate(int)}. Tests
	 * the setAmtChocolate method when the amount chocolate entered is greater
	 * than zero.
	 */
	@Test
	public void testSetAmtChocolate()
	{
		r1.setAmtChocolate(5);
		assertEquals(5, r1.getAmtChocolate());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setAmtChocolate(int)}. Tests
	 * the setAmtChocolate method when the amount chocolate entered is less than
	 * zero.
	 */
	@Test
	public void testSetAmtChocolate_E4()
	{
		r1.setAmtChocolate(-5);
		assertEquals(0, r1.getAmtChocolate());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#getAmtCoffee()}.
	 */
	@Test
	public void testGetAmtCoffee()
	{
		assertEquals(6, r1.getAmtCoffee());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setAmtCoffee(int)}. Tests
	 * the setAmtCoffee method when the amount coffee entered is greater than
	 * zero.
	 */
	@Test
	public void testSetAmtCoffee()
	{
		r1.setAmtCoffee(5);
		assertEquals(5, r1.getAmtCoffee());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setAmtCoffee(int)}. Tests
	 * the setAmtCoffee method when the amount coffee entered is less than zero.
	 */
	@Test
	public void testSetAmtCoffee_E4()
	{
		r1.setAmtCoffee(-5);
		assertEquals(0, r1.getAmtCoffee());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#getAmtMilk()}.
	 */
	@Test
	public void testGetAmtMilk()
	{
		assertEquals(1, r1.getAmtMilk());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setAmtMilk(int)}. Tests the
	 * setAmtMilk method when the amount milk entered is greater than zero.
	 */
	@Test
	public void testSetAmtMilk()
	{
		r1.setAmtMilk(5);
		assertEquals(5, r1.getAmtMilk());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setAmtMilk(int)}. Tests the
	 * setAmtMilk method when the amount milk entered is less than zero.
	 */
	@Test
	public void testSetAmtMilk_E4()
	{
		r1.setAmtMilk(-5);
		assertEquals(0, r1.getAmtMilk());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#getAmtSugar()}.
	 */
	@Test
	public void testGetAmtSugar()
	{
		assertEquals(1, r1.getAmtSugar());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setAmtSugar(int)}. Tests the
	 * setAmtSugar method when the amount sugar entered is greater than zero.
	 */
	@Test
	public void testSetAmtSugar()
	{
		r1.setAmtSugar(5);
		assertEquals(5, r1.getAmtSugar());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setAmtSugar(int)}. Tests the
	 * setAmtSugar method when the amount sugar entered is less than zero.
	 */
	@Test
	public void testSetAmtSugar_E4()
	{
		r1.setAmtSugar(-5);
		assertEquals(0, r1.getAmtSugar());
	}



	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Recipe#getName()}.
	 */
	@Test
	public void testGetName()
	{
		assertEquals("Coffee", r1.getName());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setName(java.lang.String)}.
	 */
	@Test
	public void testSetName()
	{
		r1.setName("Latte");
		assertEquals("Latte", r1.getName());
	}



	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Recipe#getPrice()}.
	 */
	@Test
	public void testGetPrice()
	{
		assertEquals(50, r1.getPrice());
	}



	/**
	 * Test method for.
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setPrice(int)}. Tests the
	 * setAmtSugar method when the price entered is greater than zero.
	 */
	@Test
	public void testSetPrice()
	{
		r1.setPrice(10);
		assertEquals(10, r1.getPrice());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#setPrice(int)}. Tests the
	 * setAmtSugar method when the price entered is less than zero.
	 */
	@Test
	public void testSetPrice_E4()
	{
		r1.setPrice(-10);
		assertEquals(0, r1.getPrice());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#equals(edu.towson.cosc603.coffeemaker.Recipe)}
	 * . Tests the equals method when two recipes are equal.
	 */
	@Test
	public void testEqualsRecipe_True()
	{
		Recipe r2 = r1;

		assertTrue(r1.equals(r2));
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Recipe#equals(edu.towson.cosc603.coffeemaker.Recipe)}
	 * . Tests the equals method when two recipes aren't equal.
	 */
	@Test
	public void testEqualsRecipe_False()
	{
		Recipe r2 = r1;

		r2.setName(null);
		assertFalse(r1.equals(r2));
	}



	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Recipe#toString()}.
	 */
	@Test
	public void testToString()
	{
		assertEquals("Coffee", r1.toString());
	}

}
